package com.hgyc.mom.base.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hgyc.mom.base.entity.BomItem;
import com.hgyc.mom.base.service.BomItemService;
import com.hgyc.mom.common.vo.Result;
import com.hgyc.mom.core.mybatis.QueryWrapperUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 产品BOMController
 *
 * @author fwj
 * @since 2025-07-10
 */
@Tag(name = "产品BOM控制器", description = "产品BOM控制器")
@RestController
@RequestMapping("/base/bom/item")
public class BomItemController {
    @Autowired
    private BomItemService bomItemService;

    @Operation(summary = "查询产品BOM树列表", description = "查询产品BOM树列表")
    @PostMapping("/list")
    public Result<List<BomItem>> pageList(@Parameter(description = "查询参数") @RequestBody BomItem bomItem) {
        QueryWrapper<BomItem> wrapper = QueryWrapperUtil.build(bomItem);
        List<BomItem> list = bomItemService.list(wrapper);
        return Result.success(list);
    }

    @Operation(summary = "获取产品BOM详细信息", description = "获取产品BOM详细信息")
    @GetMapping(value = "/{id}")
    public Result getInfo(@Parameter(description = "产品BOMID") @PathVariable("id") Long id) {
        return Result.success(bomItemService.getById(id));
    }

}